// 过滤器
import { dateFormat } from "@/util/date";

export const toBool = (bool)=>{
    return bool ? "是" : "否";
};

// 状态过滤器
export const fStatus = (bool)=>{
    return bool ? "激活" : "冻结";
};

// 格式化日期
export function fDate(date, fat) {
    if(!date){
        return "";
    }
    date = new Date(date);
    return dateFormat(date, fat);
}
// 更改菜单配置

export function isDisabled(value) {
    if(!value){
        return false;
    }
    let status = value.every((item) => {
        return !!item.isCreated;
    });
    return status;
}
// 类型过滤器
export function equipmentType (value) {
    let result  = null;
    switch (value) {
        case 'Door':
            result = '门';
            break;
          case 'Elevator':
            result = '电梯';
          break;
          case 'Role':
            result = '群组';
          break;
          default:
            result = null;
            break;
    }
    return result;

}
// 类型过滤器
export function userType (value) {
    let result  = null;
    switch (value) {
        case 'Role':
            result = '角色';
            break;
          case 'Dept':
            result = '部门';
          break;
          default:
            result = null;
            break;
    }
    return result;

}
export function colorType (status) {
    let result = null;
    switch (status) {
        case 2:
            result = 'rgb(240, 143, 0)';
            break;
        case 3:
            result = 'rgb(107, 179, 119)'
            break;
        case 7:
            result = 'rgb(153, 153, 153)'
            break;
        default:
            result = 'rgb(240, 143, 0)';
            break
    }
    return result;
}
// 审核状态
export function approveStatus (status) {
    let result = null;
    switch (status) {
        case 2:
            result = '审核中';
            break;
        case 3:
            result = '已审核'
            break;
        case 7:
            result = '已结算'
            break;
        case 8:
            result = '已拒绝 '
            break;
        default:
            result = '审核中';
            break
    }
    return result;
}